Leadtools.ImageProcessing.Effects Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
UserFilterCommand Constructor(Int32,Int32,Point,Int32,Int32,UserFilterCommandType,Int32[])
See Also  Example
Leadtools.ImageProcessing.Effects Namespace > UserFilterCommand Class > UserFilterCommand Constructor : UserFilterCommand Constructor(Int32,Int32,Point,Int32,Int32,UserFilterCommandType,Int32[])



filterWidth
Number of columns in the user-defined array (mask). This parameter only accepts positive values.
filterHeight
Number of rows in the user-defined array (mask). This parameter only accepts positive values.
centerPoint
Any two-dimensional position of the matrix array, to be used as the matrix (mask)center.
divisor
Value used to divide the final result of the output. This must be a non-zero value. If you want to use floating point values for the matrix elements and the divisor, multiply the matrix elements and the divisor with the same value (for example, 10, 100, 1000). This parameter only accepts positive values.
offset
Value used to offset the final result of the output.
type
Flag that indicates the type of operation.
matrix
Array of (filterWidth * filterHeight) integers containing the user-defined matrix (mask). The elements are stored in row order (first row, second row, etc).
Initializes a new UserFilterCommand class object with explicit parameters.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal filterWidth As Integer, _
   ByVal filterHeight As Integer, _
   ByVal centerPoint As Point, _
   ByVal divisor As Integer, _
   ByVal offset As Integer, _
   ByVal type As UserFilterCommandType, _
   ByVal matrix() As Integer _
)
Visual Basic (Usage)Copy Code
Dim filterWidth As Integer
Dim filterHeight As Integer
Dim centerPoint As Point
Dim divisor As Integer
Dim offset As Integer
Dim type As UserFilterCommandType
Dim matrix() As Integer
 
Dim instance As UserFilterCommand(filterWidth, filterHeight, centerPoint, divisor, offset, type, matrix)
C# 
public UserFilterCommand( 
   int filterWidth,
   int filterHeight,
   Point centerPoint,
   int divisor,
   int offset,
   UserFilterCommandType type,
   int[] matrix
)
C++/CLI 
public:
UserFilterCommand( 
   int filterWidth,
   int filterHeight,
   Point centerPoint,
   int divisor,
   int offset,
   UserFilterCommandType type,
   array<int>^ matrix
)

Parameters

filterWidth
Number of columns in the user-defined array (mask). This parameter only accepts positive values.
filterHeight
Number of rows in the user-defined array (mask). This parameter only accepts positive values.
centerPoint
Any two-dimensional position of the matrix array, to be used as the matrix (mask)center.
divisor
Value used to divide the final result of the output. This must be a non-zero value. If you want to use floating point values for the matrix elements and the divisor, multiply the matrix elements and the divisor with the same value (for example, 10, 100, 1000). This parameter only accepts positive values.
offset
Value used to offset the final result of the output.
type
Flag that indicates the type of operation.
matrix
Array of (filterWidth * filterHeight) integers containing the user-defined matrix (mask). The elements are stored in row order (first row, second row, etc).

Example

Run the UserFilterCommand on an image, In this example the high pass.filter will be applied using user defined matrix.

Visual BasicCopy Code
Public Sub UserFilterConstructorExample()
   RasterCodecs.Startup()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim leadImage As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Master.jpg")

   ' Prepare the command
   Dim i As Integer
   Dim j As Integer
   Dim matrix() As Integer
   ReDim matrix(8)

   ' Initialize the array with factor used to apply the high pass filter.
   For i = 0 To 2
      For j = 0 To 2
         If (j = 1 Or i = 1) Then
            If (j = 1 And i = 1) Then
               matrix(i * 3 + j) = 5
            Else
               matrix(i * 3 + j) = -1
            End If
         Else
            matrix(i * 3 + j) = 0
         End If
      Next
   Next

   Dim command As UserFilterCommand = New UserFilterCommand(3, 3, New Point(1, 1), 1, 0, UserFilterCommandType.Sum, matrix)
   ' Apply the high pass custom filter.
   command.Run(leadImage)
   codecs.Save(leadImage, LeadtoolsExamples.Common.ImagesPath.Path + "Result.jpg", RasterImageFormat.Jpeg, 24)

   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void UserFilterConstructorExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Master.jpg"); 
 
   // Prepare the command 
   int [] matrix = new int[9]; 
 
   // Initialize the array with factor used to apply the high pass filter. 
   for(int i = 0; i < 3; i++) 
   { 
      for(int j = 0; j < 3; j++) 
      { 
         if(j == 1 || i == 1) 
         { 
            if(j == 1 && i == 1) 
               matrix[i * 3 + j] = 5; 
            else  
               matrix[i * 3 + j] = -1; 
         } 
         else 
            matrix[i * 3 + j] = 0; 
      } 
   } 
 
   UserFilterCommand command = new UserFilterCommand(3, 3, new Point(1, 1), 1, 0, UserFilterCommandType.Sum, matrix); 
   // Apply the high pass custom filter. 
   command.Run(image); 
 
   RasterCodecs.Shutdown(); 
}

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also